package main

import (
	"fmt"
	"runtime"

	"github.com/spf13/cobra"

	"gitverse.ru/nickolasfox/kek/pkg/tools"

	"gitverse.ru/nickolasfox/kek-registry/pkg"
	"gitverse.ru/nickolasfox/kek-registry/pkg/app"
)

var (
	rootCmd    = app.New().Register()
	versionCmd = &cobra.Command{
		Use:     "version",
		Aliases: []string{"ver", "v"},
		Short:   "Show application version",
		Run: func(cmd *cobra.Command, _ []string) {
			_, _ = fmt.Fprintf(cmd.OutOrStdout(), "%[1]s version: %[2]s, %[3]s/%[4]s %[5]s",
				pkg.AppName,       // 1
				pkg.AppVersion,    // 2
				runtime.GOOS,      // 3
				runtime.GOARCH,    // 4
				runtime.Version(), // 5
			)
		},
	}
)

func main() {
	rootCmd.AddCommand(versionCmd)
	tools.ExitOnErr(rootCmd.Execute())
}
